if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_KhachHang_KhachHangNhaCungCap_Insert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_KhachHang_KhachHangNhaCungCap_Insert]
GO
CREATE PROC [sp_KhachHang_KhachHangNhaCungCap_Insert]
	@Ten					nvarchar(50),
	@Ma_khu_vuc				int,
	@Ma_nhom_khach_hang		int,
	@Dia_chi				nvarchar(500),
	@Tel					nvarchar(40),
	@Fax					nvarchar(40),
	@Email					nvarchar(50),
	@So_tai_khoan			nvarchar(40),
	@Ngan_hang				nvarchar(40),
	@Ma_so_thue				nvarchar(40),
	@Ghi_chu				nvarchar(100)

AS
BEGIN
	DECLARE @Ngay_cap_nhat_cuoi datetime
	SET @Ngay_cap_nhat_cuoi = getdate()
	INSERT INTO KhachHang(
					Ten,
					Ma_khu_vuc,
					Ma_nhom_khach_hang,
					Dia_chi,
					Tel,
					Fax,
					Email,
					So_tai_khoan,
					Ngan_hang,
					Ma_so_thue,
					Ghi_chu,
					Ngay_cap_nhat_cuoi
				)
	VALUES(				
		@Ten,
		@Ma_khu_vuc,
		@Ma_nhom_khach_hang,
		@Dia_chi,
		@Tel,
		@Fax,
		@Email,
		@So_tai_khoan,
		@Ngan_hang,
		@Ma_so_thue,
		@Ghi_chu,
		@Ngay_cap_nhat_cuoi
	)
END
